package org.jetlinks.community.messaging.rabbitmq;

import org.jetlinks.community.messaging.rabbitmq.command.CreateConsumer;
import org.jetlinks.community.messaging.rabbitmq.command.admin.AdminCommand;
import org.jetlinks.community.datasource.Command;
import org.jetlinks.community.datasource.DataSource;
import org.jetlinks.community.datasource.DataSourceType;

import javax.annotation.Nonnull;

/**
 * @see CreateConsumer
 * @see AdminCommand
 */
public interface RabbitMQDataSource extends DataSource {

    DataSourceType type = Type.instance;

    AdminRabbitProperties getConfig();

    AdminRabbitProperties copyConfig();

    @Nonnull
    @Override
    <R> R execute(@Nonnull Command<R> command);

    @Override
    default DataSourceType getType() {
        return RabbitMQDataSource.type;
    }

    enum Type implements DataSourceType {
        instance;

        @Override
        public String getId() {
            return "rabbitmq";
        }

        @Override
        public String getName() {
            return "RabbitMQ";
        }
    }
}
